home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / CONTAXON / BKTANCON.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.7 KB  |  50 lines

  1. // Dynamic link library implementation of NeuroSolutions BackTanhContextAxon component 
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /********************************/
  6. /* Backpropagation of component */
  7.  
  8. __declspec(dllexport) void performBackContextAxon(
  9.     DLLData *instance,    // Pointer to instance data (may be NULL)
  10.     DLLData *dualInstance,    // Pointer to the forward axons instance data (may be NULL)
  11.     NSFloat    *error,     // Pointer to the current error vector
  12.     int     rows,        // Number of rows of PEs in the layer
  13.     int     cols,        // Number of columns of PEs in the layer
  14.     NSFloat    *delayedError,     // Pointer to the last error vector (delayed by one time step)
  15.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  16.     NSFloat    *tau,        // Pointer to a vector of time constants, one for each PE
  17.     NSFloat    beta,        // Linear scaling factor controlled within the components inspector
  18.     NSFloat    *gradient     // Pointer to the tau gradient vector
  19.     )
  20.     
  21. {
  22.     int i, length=rows*cols;
  23.  
  24.     for (i=0; i<length; i++) {
  25.         error[i] *= 1.0f - data[i]*data[i] + 0.1f;
  26.         error[i] = beta*(data[i] + tau[i]*delayedError[i]);
  27.         if (gradient)
  28.             gradient[i] += delayedError[i]*beta*data[i];
  29.     } 
  30. }
  31.  
  32. /******************************************/
  33. /* Management of instance data (OPTIONAL) */
  34. /*
  35. __declspec(dllexport) DLLData *allocBackContextAxon(
  36.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  37.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  38.     int     rows,        // Number of rows of PEs in the layer
  39.     int     cols        // Number of columns of PEs in the layer
  40.     )
  41. {
  42.     DLLData *instance = allocDLLInstance(oldInstance);
  43.     return instance;
  44. }
  45.  
  46. __declspec(dllexport) void freeBackContextAxon(DLLData *instance)
  47. {
  48.     freeDLLInstance(instance);
  49. }
  50. */